#!/bin/bash

source timer.sh

function chk() {
	if [ $? != 0 ]
	then
		echo " $1 failed."
		wget --quiet "http://bmailsms.sa.nhnsystem.com:20080/message/sendSms.action?recvNum=01099289272&sendNum=01054775677&sendMsg=${1}_failed"
		rm sendSms.action*
		exit 2
	fi
}

function sms() {
		msg="`date` $@"
		echo $msg
		wget --quiet "http://bmailsms.sa.nhnsystem.com:20080/message/sendSms.action?recvNum=01099289272&sendNum=01054775677&sendMsg=${msg}"
		rm sendSms.action*
}

function run_service()
{
	sms 'Start' $1
	t=$(timer)
	python $1.py $2
	chk $1.py
	elapsed_time=$(timer $t)
	printf 'Elapsed Time: $elapsed_time\n'
	sms 'End ' $elapsed_time
}
